package com.tbs.parkingsaleapp.Http.Listenner;

import android.content.Intent;
import android.widget.Toast;
import com.tbs.parkingsaleapp.Http.HttpHelper;
import com.tbs.parkingsaleapp.Http.IAsycHttpBackgroundAction;
import com.tbs.parkingsaleapp.Http.IAsycHttpResultAction;
import com.tbs.parkingsaleapp.Http.JsonData.LikeInfo;
import com.tbs.parkingsaleapp.SystemManager.NetWorkSetting;
import com.tbs.parkingsaleapp.UI.FaceTakeActivity;
import com.tbs.parkingsaleapp.UI.UpdateLike.UpdateLikeActivity;

public class UpdateLikeHttper implements IAsycHttpBackgroundAction<String,Integer>, IAsycHttpResultAction<Integer> {

    UpdateLikeActivity activity;
    int k;
    public UpdateLikeHttper(UpdateLikeActivity activity)
    {
        this.activity=activity;
    }
    @Override
    public Integer BackGroundAction(String... params) throws Exception{
        String r= HttpHelper.Get(NetWorkSetting.UpdateLikeUrl(params[0],params[1]));
        k=Integer.valueOf(params[1]);
        return Integer.valueOf(r.trim());
    }

    @Override
    public void ResultFunction(Integer result) {
        switch (result)
        {
            case 0:
                Toast.makeText(activity, "无效用户", Toast.LENGTH_SHORT).show();
                break;
            case 1:
                Intent rx=new Intent();
                rx.putExtra(UpdateLikeActivity.UPDATEKEY,k);
                activity.setResult(UpdateLikeActivity.UPDATED,rx);
                activity.finish();
                break;
            case -1:
                Toast.makeText(activity, "提交错误", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
